package com.heima.mapper;

import com.heima.entry.FindNotWorkByTime;
import com.heima.entry.NotWorkUser;
import com.heima.entry.UserPractice;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @ClassName UserPracticeMapper
 * @Author Administrator
 * @create 2022/11/13 14:28
 */
@Mapper
@Transactional
public interface UserPracticeMapper {


    List<UserPractice> findAll(@Param("time") String time,@Param("type") Integer type);

    @Select(" SELECT" +
            " u.id ," +
            " usa.user_id uid," +
            " u.name," +
            " usa.created_on ," +
            " COUNT(*) count " +
            " FROM" +
            " USER u" +
            " INNER JOIN user_student_assignment usa ON u.id = usa.user_id " +
            " WHERE" +
            " usa.created_on between #{startTime} and #{endTime} " +
            " AND usa.assignment_type = #{type}" +
            " GROUP BY id,usa.`status`" +
            " HAVING usa.`status` = '1'")
    List<NotWorkUser> findNotWorkByTime(@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("type")Integer type);
}
